package cn.wsalix.finance.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.type.WasteBodyEnum;
import cn.wsalix.type.WasteTypeEnum;

@Entity
@DynamicInsert @DynamicUpdate
@Table(name = "CARD_WASTE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Data
@EqualsAndHashCode(callSuper=false)
public class CardWaste extends SimpleEntity  {

	private static final long serialVersionUID = 1866474821139185112L;

	private String number;//卡号
	private Integer amount;//费用记录/客户还款金额
	private Integer totalAmount;//客户付款总金额
	private Integer serverAmount;//服务费金额
	@Temporal(TemporalType.TIMESTAMP) //消费时间 
	private Date wasteday;
	private WasteBodyEnum wasteBody;//业务主体 公司、客户
	private WasteTypeEnum wasteType;//业务类型
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_CARDWASTE_CARD"), name = "CARD_ID")
	private CreditCard creditCard;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_CARDWASTE_CUSTOMER"), name = "CUSTOMER_ID")
	private Customer customer;
}
